package homework.test5;

import java.text.SimpleDateFormat;
import java.util.Date;

/*
每1秒循环1次，每次循环按“yyyy-MM-dd HH:mm:ss”的格式打印当前系统时间。
 */
public class MyThread extends Thread{
    @Override
    public void run() {
        for (int i=0; i < 10; i++) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            long time = System.currentTimeMillis();
            Date date = new Date(time);

            String t = sdf.format(date);
            System.out.println(t);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
